package com.qf.flash.mvp.presenter;

import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.http.HttpManager;
import com.qf.flash.http.response.GameDetailResponse;
import com.qf.flash.mvp.contract.GameMemberContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

import java.util.List;

public class GameMemberPresenter extends BasePresenter<GameMemberContract.View> implements GameMemberContract.Presenter {
    @Override
    public void getMembersList(String orderId) {
        String uid = UserMgr.getInstance().getLoginUser().getUid();
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .GAME_MEMBERS(uid, orderId)
                .compose(RxUtils.handleResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<List<GameDetailResponse.UsersBean>>(mRootView) {
                                   @Override
                                   public void onSuccess(List<GameDetailResponse.UsersBean> usersBean) {
                                       mRootView.setMembersData(usersBean);
                                   }
                               }
                )
        );
    }
}
